#ifndef CONNECTORENTITY_H
#define CONNECTORENTITY_H

#include "../ecs/entity.h"
#include "pinentity.h"

class DeleteItem;
class ConnectorEntity : public Entity
{
    Q_OBJECT
public:
    ConnectorEntity(QGraphicsItem* parent = nullptr, PinEntity* start = nullptr, PinEntity* end = nullptr);
    QRectF boundingRect() const override;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
    QPainterPath shape() const override;
    void removeSelf() override;
    QJsonObject toJsonObject() override;
    void tick(const int& msec = 0) override;

    void initConnections();

public slots:
    void onStartPinDestroy();
    void onEndPinDestroy();

signals:

protected:
    void mousePressEvent(QGraphicsSceneMouseEvent *event) override;

private:
    PinEntity* mStartPin;
    PinEntity* mEndPin;
    int mLineWidth;
    QPointF mStartPoint;
    QPointF mEndPoint;
    PinDirection mStartDirection;
    PinDirection mEndDirection;
};

#endif // CONNECTORENTITY_H
